#include "buff.h"
int buff::buffpos[3][3];
buff::buff()
{

}
void buff::setbuff(int c)
{
    int a,b;
    do{a=int(rand()%26);b=int(rand()%26);}
    while(maps::mmap[a][b]>3);
    int d=int(rand()%3)+1;
    buff::buffpos[c][0]=d;
    buff::buffpos[c][1]=b;
    buff::buffpos[c][2]=a;
};
void buff::initbuff()
{for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            buff::buffpos[i][j]=0;
        }
    }
    timer =new QTimer;
    timer->start(15);
    connect(timer,SIGNAL(timeout()),SLOT(buffupdate()));
};
void buff::buffupdate()
{
    update+=1;
    if(update<150){return;}
    for(int i=0;i<3;i++)
    {
       if(buff::buffpos[i][0]==0)
       {setbuff(i);break;}
    }
    update=0;
};
